{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "my = pd.read_csv('maoyanfilms_clean.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3156, 2174, 920, 1910, 5189, 1453, 400, 228]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# my['films_duration'] = my['films_duration'].apply(lambda x: int(x[:-2]))\n",
    "films_duration_count = [0]*8 # 电影时长统计列表 分8个部分 0~140 7份 + >140\n",
    "films_duration_range = ['0~19','20~39','40~59','60~79','80~99','100~119','120~139','>=140']\n",
    "for one in my['films_duration']:\n",
    "    d = int(one[:-2])\n",
    "    if d < 140:\n",
    "        for i in range(0,len(films_duration_count)-1):\n",
    "            if d in range(20*i,20*i+20):\n",
    "                films_duration_count[i] +=1\n",
    "    else:\n",
    "        films_duration_count[7] +=1\n",
    "films_duration_count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "from pyecharts.faker import Faker\n",
    "c = (\n",
    "    Funnel()\n",
    "    .add(\"电影时长统计图\", [list(z) for z in zip(films_duration_range, films_duration_count)])\n",
    "    .render(\"不同电影时长统计图.html\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
